package com.bookshop.book.data;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import com.bookshop.dataOperator.DatabaseUtils;

public class ListCatagory {
   public String[] listCatagory(){
	   ArrayList<String> resultArrayList = new ArrayList<>();
	   
	   String sql="select catagory from catagory";
		PreparedStatement psmt = DatabaseUtils.pd(sql);
        
		try {
			ResultSet rs = psmt.executeQuery();
			while(rs.next()){
				resultArrayList.add(rs.getString(1));
			}
			String[] result = new String[resultArrayList.size()];
			return resultArrayList.toArray(result);
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		}
	   
   }
}
